<?php
require_once("config/db.php");
// start a php array which we will return as ajax to our javascript (eventually)
if (isset($_POST['survey_id'])) {
 	$con=mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
	// Check connection
	if (mysqli_connect_errno()) {
	  	echo "Failed to connect to MySQL: " . mysqli_connect_error();
	}

	$surveyId = $_POST['survey_id'];
	$jsonArray = array();

	$sql = 'SELECT survey_name, creator_name, length, status FROM survey WHERE survey_id='.$surveyId ;
	
	$result = mysqli_query($con,$sql);
	$users;

	if ($row = mysqli_fetch_array($result)) 
	{
		$surveyInfo = array('survey_name' => $row['survey_name'], 
						  'creator_name' => $row['creator_name'], 
						  'length' => $row['length'],
						  'status' => $row['status']);
		mysqli_close($con);
		echo json_encode($surveyInfo);	
	}
}
else
{echo "There's no survey like that";}
?>
